//
//  ZWInstallViewController.m
//  wan
//
//  Created by apple on 16/2/23.
//  Copyright © 2016年 MyCompany. All rights reserved.
//

#import "ZWInstallViewController.h"
#import "UIBarButtonItem+CH.h"
#import "ZWHeader.h"
#import "ZWEditCell.h"

@interface ZWInstallViewController () <UITableViewDataSource, UITableViewDelegate>

@end

@implementation ZWInstallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置导航栏
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"返回" target:self action:@selector(returnClick)];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"顶部"] forBarMetrics:UIBarMetricsDefault];
    self.navigationItem.title = @"设置";
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor colorWithWhite:0.1 alpha:1.0], NSFontAttributeName:[UIFont boldSystemFontOfSize:15]};
    
    //设置tableview
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.rowHeight = 60;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
}

- (void)returnClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    } else if (section == 1) {
        return 4;
    } else if (section == 2) {
        return 2;
    } else {
        return 1;
    }
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *ID = @"ID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }        
    cell.textLabel.font = [UIFont systemFontOfSize:13];
    
    if (indexPath.section == 0) {
        cell.textLabel.text = @"仅在wifi环境下联网";
        UISwitch *wifiSwitch = [[UISwitch alloc] init];
        cell.accessoryView.frame = CGRectMake(0, 0, 40, 20);
        cell.accessoryView = wifiSwitch;
    } else if (indexPath.section == 1) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        if (indexPath.row == 0) {
            cell.textLabel.text = @"不爽，我要吐槽";
        } else if (indexPath.row == 1) {
            cell.textLabel.text = @"喜欢玩儿,给个好评";
        } else if (indexPath.row == 2) {
            cell.textLabel.text = @"用户许可协议和版权声明";
        } else {
            cell.textLabel.text = @"关于玩儿";
        }
    } else if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            cell.textLabel.text = @"检测更新";
            UILabel *updateLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 40, 20)];
            updateLable.text = @"v0.0.1";
            updateLable.font = [UIFont systemFontOfSize:14];
            cell.accessoryView = updateLable;
        } else {
            cell.textLabel.text = @"修改密码";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
 
        }
    } else {
        ZWEditCell *editcell = [[ZWEditCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ID"];
        return editcell;
    }
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 38;
    } else {
        return 2;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        
    } else if (indexPath.section == 1) {
        if (indexPath.row == 0) {
            
        } else if (indexPath.row == 1) {
            
        } else if (indexPath.row == 2) {
            
        } else {
            
        }
    } else if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            
        } else {
            
        }
    } else {
        
    }
}


@end
